import axios from 'axios';
import {API_NEW_VERSION} from '../api';

let qs = require('qs');

// 路径  start

const SIGN_OFFS = API_NEW_VERSION + 'sign_offs';

const SIGN_OFF = API_NEW_VERSION + 'sign_off';

const SIGN_OFF_TASK_BY_ID = API_NEW_VERSION + 'sign_off_task_by/';

const SIGN_OFF_SEARCH = API_NEW_VERSION + 'sign_off_search';

const SIGN_OFF_FIND_BY_SING_OFF_ID = API_NEW_VERSION + 'sign_off_pictures_find_by_sing_off_id/';

const SIGN_OFF_BY_ID = API_NEW_VERSION + 'sign_off_by/';
// 路径  end

// 获取签收任务列表
export const searchSignOffs = params => {
  return axios.get(SIGN_OFFS, {params: params});
};
// 保存签收任务表
export const saveSignOffTasks = (id, params) => {
  return axios.post(API_NEW_VERSION + 'sign_off/' + id + '/sign_off_tasks', params);
};

export const cancelSignOffTasks = (params) => {
  return axios.post(API_NEW_VERSION + 'sign_off_tasks/cancel', qs.stringify(params));
};

// 上传图片
export const saveSignOffPictures = (id, fileList) => {
  return axios.post(API_NEW_VERSION + 'save_sign_off_pictures', qs.stringify({id: id, fileList: fileList}));
};

// 根据条件搜索 未签收 的列表
export const searchSignOff = params => {
  return axios.get(SIGN_OFF, {params: params});
};

// 根据条件搜索 签收 的列表
export const getSignOff = params => {
  return axios.get(SIGN_OFF_SEARCH, {params: params});
};

// //获取签收任务记录列表
export const searchSignOffTasks = params => {
  return axios.get(API_NEW_VERSION + 'sign_off_tasks', {params: params});
};

// 根据ID，获取签收 任务 详情
export const getSignOffTask = id => {
  return axios.get(SIGN_OFF_TASK_BY_ID + id);
};

// 根据ID，获取签收表详情
export const getSignOffById = id => {
  return axios.get(SIGN_OFF_BY_ID + id);
};

// 根据ID，获取签收 图片 详情
export const getSignOffPicture = id => {
  return axios.get(SIGN_OFF_FIND_BY_SING_OFF_ID, {params: {id: id}});
};

export const getSignOffPage = param => {
  return axios.get(API_NEW_VERSION + 'sign_off_page', {params: param});
};

export const getAgeingWarningStatic = param => {
  return axios.get(API_NEW_VERSION + 'sign_off_ageing', {params: param});
};

export const signOffStatistics = param => {
  return axios.get(API_NEW_VERSION + 'sign_off_statistics', {params: param});
};

export const addSignOffError = (id, param) => {
  return axios.post(API_NEW_VERSION + 'sign_off/' + id + '/error', param);
};

export const getSignOffByOrderId = (orderId) => {
  return axios.get(API_NEW_VERSION + 'sign_off_by_order_id/' + orderId);
};

export const getSignOffErrorByOrderId = param => {
  return axios.get(API_NEW_VERSION + 'sign_off_error/list', {params: param});
};
